<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>提醒事项</title>
    <script src="../js/vue.js"></script>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            display: flex;
            flex-direction: column;
            align-items: center;
            background-color: #f4f4f4;
        }

        /* 头部盒子 */
        .header-container {
            width: 80%;
            max-width: 600px;
            background-color: #ff9500;
            /* 橙色背景 */
            color: white;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
            display: flex;
            flex-direction: column;
            align-items: flex-start;
        }

        .header-container h1 {
            font-size: 24px;
            margin: 0 0 10px 0;
            /* 标题与输入框之间的间距 */
        }

        /* 输入框和按钮的样式 */
        .input-group {
            display: flex;
            align-items: center;
            width: 100%;
            background: white;
            border-radius: 4px;
            overflow: hidden;
            /* 隐藏边框溢出部分 */
            border: 1px solid #ccc;
            /* 添加整体边框 */
        }

        .input-group .label-box {
            background-color: #e0e0e0;
            /* 灰色背景 */
            padding: 10px;
            font-weight: bold;
            color: #333;
            border-right: 1px solid #ccc;
            /* 添加分割线 */
        }

        .input-group input[type="text"] {
            flex: 1;
            padding: 10px;
            border: none;
            /* 移除输入框边框 */
            outline: none;
            /* 移除焦点时的边框 */
        }

        .input-group button {
            padding: 10px 15px;
            background-color: #28a745;
            color: white;
            border: none;
            cursor: pointer;
        }

        .input-group button:hover {
            background-color: #218838;
        }

        /* 提醒事项列表的盒子 */
        .memo-container {
            width: 80%;
            max-width: 600px;
            background: white;
            padding: 20px;
            border-radius: 8px;
            margin-top: 0;
            /* 移除头部盒子与提醒事项盒子之间的间距 */
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
        }

        .memo-list {
            list-style-type: none;
            padding: 0;
        }

        .memo-list li {
            display: flex;
            align-items: center;
            justify-content: space-between;
            /* 文字左对齐，按钮右对齐 */
            background: #f9f9f9;
            padding: 10px;
            margin-bottom: 10px;
            border: 1px solid #ddd;
            border-radius: 4px;
        }

        .memo-list li span {
            font-weight: bold;
        }

        .memo-list li .buttons {
            display: flex;
            align-items: center;
        }

        .memo-list li button {
            padding: 5px 10px;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            margin-left: 5px;
            /* 按钮之间的间距 */
        }

        .memo-list li button.move-up,
        .memo-list li button.move-down {
            background-color: #007bff;
            /* 蓝色背景 */
        }

        .memo-list li button.delete {
            background-color: #dc3545;
            /* 红色背景 */
        }

        .memo-list li button.disabled {
            background-color: #ccc;
            /* 灰色背景 */
            cursor: not-allowed;
        }
		.list-enter-from{
			transform: translateX(100px);
			opacity: 0;
		}
		.list-enter-active, .list-leave-active{/*过程*/
			transition: all .5s;
		}
		.list-leave-to{/*离开的终点状态*/
			transform: translateX(-100px);
			opacity: 0;/*透明*/
		}
		/*  过渡的时间，.list- 是组件move是模式，移动*/
		.list-move{
			transition: all .5s;
		
		}
    </style>
</head>

<body>
    <div id="app">
        <!-- 头部盒子 -->
        <div class="header-container">
            <h1>提醒事项</h1>
            <div class="input-group">
                <div class="label-box">内容</div>
                <input v-model="title" type="text" id="memoInput" placeholder="输入提醒事项内容">
                <button @click="add">添加</button> <!-- 仅保留样式 -->
            </div>
        </div>
        <!-- 提醒事项列表盒子 -->
        <div class="memo-container">
			<transition-group name="list" tag="ul" id="memoList" class="memo-list">
				<li v-for="(item,index) in list" :key="item">
				    <span>{{index + 1}}.</span> {{item}}
				    <div class="buttons">
				        <button v-if="index == 0" class="move-up disabled">上移</button>
				        <button @click="shangyi(index)" v-else class="move-up">上移</button>
				        <button @click="xiayi(index)" v-if="index < list.length - 1" class="move-down">下移</button>
				        <button v-else  class="move-down disabled">下移</button>
				        <button class="delete" @click="list.splice(index,1)">删除</button>
				    </div>
				</li>
			</transition-group>
    </div>


    <script>
        Vue.createApp({
            data(){
                return{
                    title: '',
                    list:['吃饭','睡觉','学习']
                }
            },
            methods:{//方法
                add(){
                    if(this.title == ''){
                          alert('请输入提示内容')
                          return
                    }else{
                        this.list.push(this.title)
						this.title = ''
                    }
                },
                //下移
                xiayi(index){
                    this.list.splice(index + 2,0,this.list[index])
					this.list.splice(index,1)
                },
                //上移
                shangyi(index){
					this.list.splice(index - 1,0,this.list[index])
					this.list.splice(index + 1,1)
                }
            }
        }).mount("#app")
    </script>
</body>

</html>